package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.subscribe.Subscribe;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SubscribeMapper;

import com.ruoyi.system.service.ISubscribeService;

/**
 * 预约服务管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-04-08
 */
@Service
public class SubscribeServiceImpl implements ISubscribeService 
{
    @Autowired
    private SubscribeMapper subscribeMapper;

    /**
     * 查询预约服务管理
     * 
     * @param subscribeId 预约服务管理主键
     * @return 预约服务管理
     */
    @Override
    public Subscribe selectSubscribeBySubscribeId(Integer subscribeId)
    {
        return subscribeMapper.selectSubscribeBySubscribeId(subscribeId);
    }

    /**
     * 查询预约服务管理列表
     * 
     * @param subscribe 预约服务管理
     * @return 预约服务管理
     */
    @Override
    public List<Subscribe> selectSubscribeList(Subscribe subscribe)
    {
        return subscribeMapper.selectSubscribeList(subscribe);
    }

    /**
     * 新增预约服务管理
     * 
     * @param subscribe 预约服务管理
     * @return 结果
     */
    @Override
    public int insertSubscribe(Subscribe subscribe)
    {
        return subscribeMapper.insertSubscribe(subscribe);
    }

    /**
     * 修改预约服务管理
     * 
     * @param subscribe 预约服务管理
     * @return 结果
     */
    @Override
    public int updateSubscribe(Subscribe subscribe)
    {
        return subscribeMapper.updateSubscribe(subscribe);
    }

    /**
     * 批量删除预约服务管理
     * 
     * @param subscribeIds 需要删除的预约服务管理主键
     * @return 结果
     */
    @Override
    @EventListener
    public int deleteSubscribeBySubscribeIds(Integer[] subscribeIds)
    {
        for (int s = 0; s < subscribeIds.length; s++) {
            Subscribe subscribe = subscribeMapper.selectSubscribeBySubscribeId(subscribeIds[s]);
            if (subscribe.getsType()==1){
                return 0;
            }
        }
        return subscribeMapper.deleteSubscribeBySubscribeIds(subscribeIds);
    }

    /**
     * 删除预约服务管理信息
     * 
     * @param subscribeId 预约服务管理主键
     * @return 结果
     */
    @Override
    public int deleteSubscribeBySubscribeId(Integer subscribeId)
    {

        return subscribeMapper.deleteSubscribeBySubscribeId(subscribeId);
    }
}
